package com.lx.chat.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lx.bilibili.entity.Message;
import com.lx.bilibili.entity.MessageEx;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lx
 * @since 2025-03-26
 */
public interface MessageMapper extends BaseMapper<Message> {

    @Select("SELECT\n" +
            "	a.`name`,\n" +
            "	a.id,\n" +
            "	a.headimg,\n" +
            "	b.* \n" +
            "FROM\n" +
            "	`user` a,\n" +
            "	message b \n" +
            "WHERE\n" +
            "	a.id = b.uid \n" +
            "	AND (( b.uid = #{uid} AND b.recvid = #{recvId} ) OR ( b.uid = #{recvId} AND b.recvid = #{uid} ) ) \n" +
            "ORDER BY\n" +
            "	b.TIME")
    List<MessageEx> getChatMessage(int uid, int recvId);
}
